<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Perform an XSLT transformation</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-getopt.html">xslt_getopt</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-base.html">xslt_set_base</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.xslt-process" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xslt_process</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.3)</p><p class="refpurpose"><span class="refname">xslt_process</span> &mdash; <span class="dc-title">Perform an <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> transformation</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.xslt-process-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>xslt_process</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$xh</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$xmlcontainer</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$xslcontainer</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$resultcontainer</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$arguments</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$parameters</code></span>
  ]]] )</div>

  <p class="para rdfs-comment">
   The <span class="function"><strong>xslt_process()</strong></span> function is the crux of the <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym>
   extension.  It allows you to perform an <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> transformation using
   almost any type of input source - the containers.  This is accomplished
   through the use of argument buffers -- a concept taken from the <span class="productname">Sablotron</span>
   <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> processor (currently the only <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> processor this extension supports).
   The input containers default to a filename &#039;containing&#039; the document to be
   processed. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xslt-process-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">
xh</code></em></dt>
<dd>
<p class="para"><acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> 处理器连接标识符，由
<span class="function"><a href="function.xslt-create.html" class="function">xslt_create()</a></span> 创建。</p></dd>


    
     <dt>
<em><code class="parameter">xmlcontainer</code></em></dt>

     <dd>

      <p class="para">
       Path to <acronym title="eXtensible Markup Language">XML</acronym> file or placeholder for the
       <acronym title="eXtensible Markup Language">XML</acronym> argument.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">xslcontainer</code></em></dt>

     <dd>

      <p class="para">
       Path to <acronym>XSL</acronym> file or placeholder for the
       <acronym title="eXtensible Markup Language">XML</acronym> argument.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">resultcontainer</code></em></dt>

     <dd>

      <p class="para">
       The result container defaults to a filename for the transformed
       document. If the result container is not specified - i.e. <strong><code>NULL</code></strong>
       - than the result is returned.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">arguments</code></em></dt>

     <dd>

      <p class="para">
       Instead of files as the <acronym title="eXtensible Markup Language">XML</acronym> and <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> arguments to the <span class="function"><strong>xslt_process()</strong></span>
       function, you can specify &quot;argument place holders&quot; which are then substituted by values
       given in the <em><code class="parameter">arguments</code></em> array.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">parameters</code></em></dt>

     <dd>

      <p class="para">
       An array for any top-level parameters that will be passed to the XSLT
       document.  These parameters can then be accessed within your XSL files
       using the <em>&lt;xsl:param name=&quot;parameter_name&quot;&gt;</em>
       instruction. The parameters must be UTF-8 encoded and their values will be
       interpreted as strings by the <span class="productname">Sablotron</span> processor.
       In other words - you cannot pass <em>node-sets</em> as parameters to
       the <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> document.
      </p>
     </dd>

    
   </dl>

  </p>
  <p class="para">
   Containers can also be set via the <em><code class="parameter">arguments</code></em>
   array (see below).
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xslt-process-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。 If the result container is not specified - i.e.
   <strong><code>NULL</code></strong> - than the result is returned.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.xslt-process-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.0.6</td>
       <td>
        This function no longer takes XML strings in
        <em><code class="parameter">xmlcontainer</code></em> or 
        <em><code class="parameter">xslcontainer</code></em>. Passing a string containing XML
        to either of these parameters will result in a segmentation fault in
        Sablotron versions up to and including version 0.95.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.xslt-process-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   The simplest type of transformation with the
   <span class="function"><strong>xslt_process()</strong></span> function is the transformation of an
   <acronym title="eXtensible Markup Language">XML</acronym> file with an <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> file, placing the result
   in a third file containing the new <acronym title="eXtensible Markup Language">XML</acronym> (or HTML) document.  Doing
   this with <span class="productname">Sablotron</span> is really quite easy...
  </p>
  <div class="example" id="example-5431">
   <p><strong>Example #1 Using the <span class="function"><strong>xslt_process()</strong></span> to transform an <acronym title="eXtensible Markup Language">XML</acronym>
   file and a <acronym>XSL</acronym> file to a new <acronym title="eXtensible Markup Language">XML</acronym> file</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Allocate&nbsp;a&nbsp;new&nbsp;XSLT&nbsp;processor<br /></span><span style="color: #0000BB">$xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Process&nbsp;the&nbsp;document<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sample.xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sample.xsl'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'result.xml'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"SUCCESS,&nbsp;sample.xml&nbsp;was&nbsp;transformed&nbsp;by&nbsp;sample.xsl&nbsp;into&nbsp;result.xml"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">",&nbsp;result.xml&nbsp;has&nbsp;the&nbsp;following&nbsp;contents\n&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">readfile</span><span style="color: #007700">(</span><span style="color: #DD0000">'result.xml'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;/pre&gt;\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Sorry,&nbsp;sample.xml&nbsp;could&nbsp;not&nbsp;be&nbsp;transformed&nbsp;by&nbsp;sample.xsl&nbsp;into"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;&nbsp;result.xml&nbsp;the&nbsp;reason&nbsp;is&nbsp;that&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">xslt_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;and&nbsp;the&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"error&nbsp;code&nbsp;is&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">xslt_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">xslt_free</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <p class="para">
   While this functionality is great, many times, especially in a web environment, you want to
   be able to print out your results directly.  Therefore, if you omit the third argument to
   the <span class="function"><strong>xslt_process()</strong></span> function (or provide a NULL value for the argument), it
   will automatically return the value of the <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> transformation, instead of writing it to a
   file...
  </p>
  <p class="para">
   <div class="example" id="example-5432">
   <p><strong>Example #2 Using the <span class="function"><strong>xslt_process()</strong></span> to transform an <acronym title="eXtensible Markup Language">XML</acronym> file
   and a <acronym>XSL</acronym> file to a variable containing the resulting XML data</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Allocate&nbsp;a&nbsp;new&nbsp;XSLT&nbsp;processor<br /></span><span style="color: #0000BB">$xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Process&nbsp;the&nbsp;document,&nbsp;returning&nbsp;the&nbsp;result&nbsp;into&nbsp;the&nbsp;$result&nbsp;variable<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sample.xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sample.xsl'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"SUCCESS,&nbsp;sample.xml&nbsp;was&nbsp;transformed&nbsp;by&nbsp;sample.xsl&nbsp;into&nbsp;the&nbsp;\$result"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;variable,&nbsp;the&nbsp;\$result&nbsp;variable&nbsp;has&nbsp;the&nbsp;following&nbsp;contents\n&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;/pre&gt;\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Sorry,&nbsp;sample.xml&nbsp;could&nbsp;not&nbsp;be&nbsp;transformed&nbsp;by&nbsp;sample.xsl&nbsp;into"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;&nbsp;the&nbsp;\$result&nbsp;variable&nbsp;the&nbsp;reason&nbsp;is&nbsp;that&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">xslt_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;and&nbsp;the&nbsp;error&nbsp;code&nbsp;is&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">xslt_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">xslt_free</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   The above two cases are the two simplest cases there are when it comes to XSLT transformation
   and I&#039;d dare say that they are the most common cases, however, sometimes you get your <acronym title="eXtensible Markup Language">XML</acronym> and
   <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> code from external sources, such as a database or a socket.  In these cases you&#039;ll have
   the <acronym title="eXtensible Markup Language">XML</acronym> and/or <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> data in a variable -- and in production applications the overhead of dumping
   these to file may be too much.  This is where <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym>&#039;s &quot;argument&quot; syntax, comes to the
   rescue.  Instead of files as the <acronym title="eXtensible Markup Language">XML</acronym> and <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> arguments to the <span class="function"><strong>xslt_process()</strong></span>
   function, you can specify &quot;argument place holders&quot; which are then substituted by values
   given in the arguments array (5th parameter to the <span class="function"><strong>xslt_process()</strong></span> function).
   The following is an example of processing <acronym title="eXtensible Markup Language">XML</acronym> and <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> into a result variable without the use
   of files at all.
  </p>
  <p class="para">
   <div class="example" id="example-5433">
   <p><strong>Example #3 Using the <span class="function"><strong>xslt_process()</strong></span> to transform a variable containing <acronym title="eXtensible Markup Language">XML</acronym> data
   and a variable containing <acronym>XSL</acronym> data into a variable containing the resulting <acronym title="eXtensible Markup Language">XML</acronym> data</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;$xml&nbsp;and&nbsp;$xsl&nbsp;contain&nbsp;the&nbsp;XML&nbsp;and&nbsp;XSL&nbsp;data<br /><br /></span><span style="color: #0000BB">$arguments&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'/_xml'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$xml</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'/_xsl'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$xsl<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Allocate&nbsp;a&nbsp;new&nbsp;XSLT&nbsp;processor<br /></span><span style="color: #0000BB">$xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Process&nbsp;the&nbsp;document<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xsl'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$arguments</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"SUCCESS,&nbsp;sample.xml&nbsp;was&nbsp;transformed&nbsp;by&nbsp;sample.xsl&nbsp;into&nbsp;the&nbsp;\$result"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;variable,&nbsp;the&nbsp;\$result&nbsp;variable&nbsp;has&nbsp;the&nbsp;following&nbsp;contents\n&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;/pre&gt;\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Sorry,&nbsp;sample.xml&nbsp;could&nbsp;not&nbsp;be&nbsp;transformed&nbsp;by&nbsp;sample.xsl&nbsp;into"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;&nbsp;the&nbsp;\$result&nbsp;variable&nbsp;the&nbsp;reason&nbsp;is&nbsp;that&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">xslt_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;and&nbsp;the&nbsp;error&nbsp;code&nbsp;is&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">xslt_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">xslt_free</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-5434">
    <p><strong>Example #4 Passing PHP variables to XSL files</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;XML&nbsp;string<br /></span><span style="color: #0000BB">$xml&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'&lt;?xml&nbsp;version="1.0"?&gt;<br />&lt;para&gt;<br />&nbsp;change&nbsp;me<br />&lt;/para&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;XSL&nbsp;string<br /></span><span style="color: #0000BB">$xsl&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'<br />&lt;xsl:stylesheet&nbsp;version="1.0"&nbsp;xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;<br />&lt;xsl:output&nbsp;method="html"&nbsp;encoding="ISO-8859-1"&nbsp;indent="no"<br />&nbsp;omit-xml-declaration="yes"&nbsp;&nbsp;media-type="text/html"/&gt;<br />&nbsp;&lt;xsl:param&nbsp;name="myvar"/&gt;<br />&nbsp;&lt;xsl:param&nbsp;name="mynode"/&gt;<br />&nbsp;&lt;xsl:template&nbsp;match="/"&gt;<br />My&nbsp;PHP&nbsp;variable&nbsp;:&nbsp;&lt;xsl:value-of&nbsp;select="$myvar"/&gt;&lt;br&nbsp;/&gt;<br />My&nbsp;node&nbsp;set&nbsp;:&nbsp;&lt;xsl:value-of&nbsp;select="$mynode"/&gt;<br />&nbsp;&lt;/xsl:template&gt;<br />&lt;/xsl:stylesheet&gt;'</span><span style="color: #007700">;<br /><br /><br /></span><span style="color: #0000BB">$xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;the&nbsp;second&nbsp;parameter&nbsp;will&nbsp;be&nbsp;interpreted&nbsp;as&nbsp;a&nbsp;string<br /></span><span style="color: #0000BB">$parameters&nbsp;</span><span style="color: #007700">=&nbsp;array&nbsp;(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'myvar'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'test'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'mynode'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'&lt;foo&gt;bar&lt;/foo&gt;'<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$arguments&nbsp;</span><span style="color: #007700">=&nbsp;array&nbsp;(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'/_xml'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$xml</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'/_xsl'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$xsl<br /></span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xsl'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$arguments</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$parameters</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
My PHP variable : test&lt;br&gt;
My node set : &amp;lt;foo&amp;gt;bar&amp;lt;/foo&amp;gt;
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-function.xslt-process-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">请注意：
在使用 Windows 时，路径必须由 <em>file://</em> 开头。</p></p></blockquote>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-getopt.html">xslt_getopt</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-base.html">xslt_set_base</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
